package com.information.manage.basic.controller;

import com.information.manage.basic.model.query.AddMenuQuery;
import com.information.manage.basic.model.query.UpdateMenuQuery;
import com.information.manage.basic.common.result.Result;
import com.information.manage.basic.service.SysMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Api(tags = "菜单权限")
@RestController
@RequestMapping("/menu")
public class SysMenuController {

    @Resource
    private SysMenuService sysMenuService;

    @PostMapping("/add")
    @ApiOperation(value = "新增菜单", notes = "新增菜单")
    public Result<Integer> addMenu(HttpServletRequest request, @RequestBody AddMenuQuery addMenuQuery){
        return sysMenuService.addMenu(request,addMenuQuery);
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "删除菜单", notes = "删除菜单")
    public Result<Boolean> deleteMenu(@RequestBody List<Integer> menuIds){
        return Result.ok(sysMenuService.deleteMenu(menuIds));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改菜单", notes = "修改菜单")
    public Result<Boolean> updateMenu(UpdateMenuQuery updateMenuQuery){
        return sysMenuService.updateMenu(updateMenuQuery);
    }

}
